package org.cuckoos.android.command;

import java.net.DatagramSocket;

import org.cuckoos.android.domain.Command;
import org.cuckoos.android.domain.Constant;
import org.cuckoos.android.domain.User;
import org.cuckoos.android.ui.AppActivity;
import org.cuckoos.android.ui.ChatPanel;

/**
 * 
 * @author bugu
 * 
 */
public class SendMsgCommand extends AbstractCommand {

	private Command command;

	public SendMsgCommand(DatagramSocket ds, User user,
			String msg) {
		super(ds);
		command = new Command(user, Constant.IPMSG_SENDMSG, msg);
	}

	public SendMsgCommand(DatagramSocket ds, ChatPanel activity) {
		super(ds);
		this.activity = activity;
	}

	@Override
	public void execute() {
		execute(command);
	}

	@Override
	public void handle(Command ac) {
		activity.showMessage(ac);
	}

	@Override
	public boolean isHandle(Command ac) {
		return Constant.GET_MODE(ac.getCommand()) == Constant.IPMSG_SENDMSG;

	}

	private ChatPanel activity;

	public ChatPanel getActivity() {
		return activity;
	}

	public void setActivity(ChatPanel activity) {
		this.activity = activity;
	}

}
